package com.gpt.article.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gpt.article.domain.GptGenArticleTask;
import com.gpt.article.service.IGptGenArticleTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 洗稿任务Controller
 * 
 * @author zhuzi
 * @date 2023-11-03
 */
@RestController
@RequestMapping("/article/task")
public class GptGenArticleTaskController extends BaseController
{
    @Autowired
    private IGptGenArticleTaskService gptGenArticleTaskService;

    /**
     * 查询洗稿任务列表
     */
    @PreAuthorize("@ss.hasPermi('article:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(GptGenArticleTask gptGenArticleTask)
    {
        startPage();
        List<GptGenArticleTask> list = gptGenArticleTaskService.selectGptGenArticleTaskList(gptGenArticleTask);
        return getDataTable(list);
    }

    /**
     * 导出洗稿任务列表
     */
    @PreAuthorize("@ss.hasPermi('article:task:export')")
    @Log(title = "洗稿任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GptGenArticleTask gptGenArticleTask)
    {
        List<GptGenArticleTask> list = gptGenArticleTaskService.selectGptGenArticleTaskList(gptGenArticleTask);
        ExcelUtil<GptGenArticleTask> util = new ExcelUtil<GptGenArticleTask>(GptGenArticleTask.class);
        util.exportExcel(response, list, "洗稿任务数据");
    }

    /**
     * 获取洗稿任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('article:task:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gptGenArticleTaskService.selectGptGenArticleTaskById(id));
    }

    /**
     * 新增洗稿任务
     */
    @PreAuthorize("@ss.hasPermi('article:task:add')")
    @Log(title = "洗稿任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GptGenArticleTask gptGenArticleTask)
    {
        return toAjax(gptGenArticleTaskService.insertGptGenArticleTask(gptGenArticleTask));
    }

    /**
     * 修改洗稿任务
     */
    @PreAuthorize("@ss.hasPermi('article:task:edit')")
    @Log(title = "洗稿任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GptGenArticleTask gptGenArticleTask)
    {
        return toAjax(gptGenArticleTaskService.updateGptGenArticleTask(gptGenArticleTask));
    }

    /**
     * 删除洗稿任务
     */
    @PreAuthorize("@ss.hasPermi('article:task:remove')")
    @Log(title = "洗稿任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gptGenArticleTaskService.deleteGptGenArticleTaskByIds(ids));
    }
}
